package com.xh.common;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCUtils {
	/** 
	     * 获取连接 
	     *  
	     */  
	    public static Connection getConnection()  
	    {  
	        String driverName = "oracle.jdbc.driver.OracleDriver";  	  
	        String url = "jdbc:oracle:thin:@10.253.66.109:1521:xhdb";  
	        String user = "xh_seye" ;  
	        String password = "xh_seye$20161024";  
	        Connection con = null ;  
	        try {  
	              
	            Class.forName(driverName);  
	            con = DriverManager.getConnection(url, user, password);  
	            System.out.println("success");  
	        } catch (Exception e) {  
	            e.printStackTrace();  
	        }  
	          
	        return con ;  
	          
	    }  
	      
	    /** 
	     * 关闭连接 
	     */  
	    public static void free(ResultSet rs, Statement sta , Connection con)  
	    {  
	        try {  
	            if(null != rs)  
	            {  
	                rs.close();  
	                rs = null ;  
	            }  
	              
	            if(null != sta)  
	            {  
	                sta.close();  
	                sta = null ;  
	            }  
	              
	            if(null != con)  
	            {  
	                con.close();  
	                con = null ;  
	            }  
	              
	        } catch (Exception e) {  
	            e.printStackTrace();  
	        }  
	    }  

}
